package com.dragon.repository.domain.dto;

import com.dragon.common.util.BeanUtils;
import com.dragon.repository.entity.AttendanceChild;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.annotation.JsonInclude;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;


/**
 * @author sy
 */
@Data
@JsonInclude(JsonInclude.Include.NON_NULL)
public class AttendanceChildDTO {

    private static final long serialVersionUID = 1L;

    @ApiModelProperty(value = "id")
    private Integer id;

    @ApiModelProperty(value = "父表id")
    private Integer attendanceId;

    @ApiModelProperty(value = "上班打卡类型：0未打卡1正常2迟到3早退")
    private Integer inClockType;

    @ApiModelProperty(value = "状态：1正常,2异常")
    private Integer status;

    @ApiModelProperty(value = "ip地址")
    private String ip;

    @ApiModelProperty(value = "电脑信息")
    private String mac;

    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone = "GMT+8")
    @ApiModelProperty(value = "打卡时间")
    private Date attendanceTime;

    @ApiModelProperty(value = "打卡地址")
    private String address;

    @ApiModelProperty(value = "签到类型：1签到,2签退")
    private Integer clockType;

//    @ApiModelProperty(value = "打卡用户id")
//    private Integer adminId;


    public AttendanceChildDTO() {}

    public AttendanceChildDTO(AttendanceChild entity) {
        BeanUtils.copyProperties(entity,this);
    }

    public static AttendanceChildDTO convert(AttendanceChild entity) {
        return new AttendanceChildDTO(entity);
    }

    public static List<AttendanceChildDTO> convertList(List<AttendanceChild> list) {
        List<AttendanceChildDTO> resultList = new ArrayList<>();
        if (resultList != null && resultList.size() != 0){
            for (AttendanceChild entity : list) {
                resultList.add(new AttendanceChildDTO(entity));
            }
            return resultList;
        }
        return resultList;

    }}
